import React, { Component } from 'react'
import Menu2 from '../menu/Menu2';
import Router2 from '../menu/Router2';
import {usermenulist} from "../interface/usermenu"
import usermenuModel from '../interface/usermenuModel';
import  {connect} from  "react-redux"
interface IState {
  list:Array<usermenuModel>
}

class List extends Component<any,IState> {
  constructor(props:any){
    super(props);
    this.state = {
      list:[],
    }
  }
  async componentDidMount(){  //请求用户的菜单路由
    let  res = await  usermenulist();
    // console.log(res);
    this.setState({
      list:res.data.list
    })

  }

  render() {
    return (
      <>
      <div>登录成功以后的页面</div>
      {this.props.flag?<Menu2 list={this.state.list}></Menu2>:""}
      
  
      <Router2 list={this.state.list}></Router2>
      </>
    )
  }
}
let  mapStateToProps = (state:any)=>({flag:state.flagInfo.flag});
let  mapDispatchToProps ={}

export  default  connect(mapStateToProps,mapDispatchToProps)(List)

